function SWFUploadTools(){

};

SWFUploadTools.instance = new SWFUploadTools();

/**
 * 创建swf上传控件,该控件可用于第三方控件（miniui）集成，用于单文件上传处理。
 * 
 * @author liuzhi 2012-08-08 
 * @param {} uploadPath 指定上传路径
 * @param {} fileTypes 文件上传类型
 * @param {} btnOwerId  控件关联表单Id
 * @param {} uploadSuccess 上传处理成功回调函数
 * 
 * @return {} 返回SWFUpload控件
 */
SWFUploadTools.createSWFUBtn = function(uploadPath, fileTypes, btnOwerId, uploadSuccess){
	if(fileTypes == null || fileTypes == ""){
		fileTypes = "*.jpg; *.gif; *.png; *.bmp";
	}
	
	var swfu = new SWFUpload({
		upload_url: __root + "/fileUploadContorller.do?uploadPath=" + uploadPath,
		flash_url : __root + "/admin/resource/swfrpc/swfupload.swf",

		file_size_limit : "1024 MB",
		file_types : fileTypes,
		file_types_description : "图片上传",
		file_upload_limit : "0",

		button_placeholder_id : btnOwerId,
		button_width: 61,
		button_height: 22,
		button_text : '<font size="12">浏览</font>',
		button_image_url : __root + "/admin/resource/swfrpc/images/fileUpload.png",  
		button_text_style : '',
		button_text_top_padding: 1,
		button_text_left_padding: 8,
		button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
		button_cursor: SWFUpload.CURSOR.HAND,
		
		debug : false,		
		file_queue_error_handler : function(){
			MiniuiTools.miniError("操作异常","文件选择错误，\n文件可能超过1024 MB或者文件类型选择有误！");
		},
		file_dialog_complete_handler : function(numFilesSelected, numFilesQueued){
			if (numFilesQueued > 0) {
				//设置为自动上传
				this.startUpload();
			}
		},
		upload_start_handler: function(file){
			MiniuiTools.miniLoading();
		},
		upload_progress_handler : function(){
		},
		upload_error_handler : function(){
			MiniuiTools.miniHideLoading();
			MiniuiTools.miniError("上传失败","文件上传失败！");
		},
		upload_success_handler : uploadSuccess
	});
	
	return swfu;
}